package teacher.clazz.student.handler;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import teacher.clazz.student.dao.CSTdao;
import teacher.clazz.student.entities.Student;
import teacher.clazz.student.service.CSTservice;

@Controller
public class Handler {

	@Autowired
	private CSTservice csTservice;
	
	@Autowired
	private CSTdao csTdao;

	// 通过老师id来查找学生信息
	@RequestMapping("/hello")
	public String test1(@RequestParam("id") Integer id,
			HttpServletRequest request) {

		List<Student> students = csTservice.teacherId(id);

		request.setAttribute("students", students);

		return "student";
	}

	// 通过学生id来查找学生信息
	@RequestMapping("/hello2")
	public String test2(@RequestParam("id") Integer id,
			HttpServletRequest request) {

		List<Student> students = csTservice.studentId2(id);

		request.setAttribute("students", students);

		return "student";
	}

	// 通过学生id来删除学生
	@RequestMapping(value = "/hello3")
	public String test3(HttpServletRequest request) {
		

		
//		request.setAttribute("message", "删除成功");
//		System.out.println(id);
		return "success";

	}

}
